package kom;

import java.awt.Rectangle;
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Float;

public class Entity {

    // this are box w/h not sprite
    protected int width = 8;
    protected int height = 8;
    protected boolean applyGravity = false;
    protected Point2D.Float aceleration = new Point2D.Float(0, 0);
    protected float acelerationSpeed = 0.2f;
    protected float standardAcelerationSpeed = 0.2f;
    protected float maxSpeed = 4f;
    protected float desacelerationSpeed = 0.2f;
    protected float standardDesacelerationSpeed = 0.2f;
    protected Rectangle box = new Rectangle();
    protected float weight = 0.8f;
    protected float x;
    protected float y;

    public void gravityTick() {
        // a boolean let me know when i need to fall or not
        // this is set in map, withc knows the tiles under its feet
        if (applyGravity) {
            float aceY = aceleration.y;
            if (aceY < 10f) {
                aceY += 0.8f;
            }
            aceleration.y = aceY;
        }
    }

    // changes position in screen 
    public void positionTick() {
        x += aceleration.getX();
        y += aceleration.getY();
        // update bounding box
        box.setBounds((int) x + 2, (int) y, width, height);
    }

    public Float getAceleration() {
        return aceleration;
    }

    public void setAceleration(Float aceleration) {
        this.aceleration = aceleration;
    }

    public float getAcelerationSpeed() {
        return acelerationSpeed;
    }

    public void setAcelerationSpeed(float acelerationSpeed) {
        this.acelerationSpeed = acelerationSpeed;
    }

    public Rectangle getBox() {
        return box;
    }

    public void setBox(Rectangle box) {
        this.box = box;
    }

    public float getDesacelerationSpeed() {
        return desacelerationSpeed;
    }

    public void setDesacelerationSpeed(float desacelerationSpeed) {
        this.desacelerationSpeed = desacelerationSpeed;
    }

    public boolean isApplyGravity() {
        return applyGravity;
    }

    public void setApplyGravity(boolean g) {
        this.applyGravity = g;
    }

    public boolean isInAir() {
        return aceleration.y != 0;
    }

    public boolean isFalling() {
        if (aceleration.y > 0) {
            return true;
        }
        return false;
    }

    public float getMaxSpeed() {
        return maxSpeed;
    }

    public void setMaxSpeed(float maxSpeed) {
        this.maxSpeed = maxSpeed;
    }

    public float getX() {
        return x;
    }

    public void setX(float x) {
        this.x = x;
    }

    public float getY() {
        return y;
    }

    public void setY(float y) {
        this.y = y;
    }
}
